/*
 * Universidade Estadual de Campinas - UNICAMP
 * MC823 - Laboratório de Redes
 * Alunos:
 *         Daniel C. Farias  RA: 059878
 *         Vitor Hugo Mickus Rodrigues RA: 072627
 * Professor:
 *         Paulo Lício e Celio
 *
 * Client program for Network Labs. Simulate an ECHO program.
 *
 */


#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>

#define CONNECT
#define PORT 3490 /* the port users will be connecting to */
#define MAXDATASIZE 300 /* max number of bytes we can get at once */
#define ALARM_TIMEOUT 1
#define MAX_NUMBER_OF_TRIES 4

#ifdef CONNECT

#define _CONNECT(sockfd, addr, addrlen) \
  connect(sockfd,addr,addrlen);

#define _SEND_TO_SERVER(sockfd, send_buf, buflen, destaddr, addrlen) \
  send(sockfd, send_buf, buflen, 0)
  
#define _RECV_FROM_SERVER(sockfd, receive_buf, max_buflen, srcaddr, addrlen) \
  recv(sockfd, receive_buf, max_buflen, 0)

#else

#define _CONNECT(sockfd, addr, addrlen)
#define _SEND_TO_SERVER(sockfd, send_buf, buflen, destaddr, addrlen) \
  sendto(sockfd, send_buf, buflen, 0, destaddr, addrlen)
      
#define _RECV_FROM_SERVER(sockfd, receive_buf, max_buflen, srcaddr, addrlen)	\
  recvfrom(sockfd, receive_buf, max_buflen, 0, srcaddr, addrlen)

#endif

